import request from '@/utils/request'
// import qs from 'qs'

// 协议分析

// 查询数据
export function getArray (params) {
  var data = fromData(params)
  return request({
    url: '/analysis/getArray',
    method: 'post',
    data
  })
}

// 获取数据分析是否开启
export function getStatus (params) {
  var data = fromData(params)
  return request({
    url: '/analysis/getStatus',
    method: 'post',
    data
  })
}

// 设置数据分析是否开启
export function setStatus (params) {
  var data = fromData(params)
  return request({
    url: '/analysis/setStatus',
    method: 'post',
    data
  })
}

// 生成策略
export function createAnalysis (params) {
  var data = fromData(params)
  return request({
    url: '/analysis/create',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
